package cn.iocoder.yudao.module.forward.dal.mysql.datasourceinfo;

import java.io.Serializable;
import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.forward.dal.dataobject.datasourceinfo.DataSourceInfoDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.forward.controller.admin.datasourceinfo.vo.*;

/**
 * 信息源配置 Mapper
 *
 * @author dfs
 */
@Mapper
public interface DataSourceInfoMapper extends BaseMapperX<DataSourceInfoDO> {

    default PageResult<DataSourceInfoDO> selectPage(DataSourceInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DataSourceInfoDO>()
                .eqIfPresent(DataSourceInfoDO::getClientId, reqVO.getClientId())
                .eqIfPresent(DataSourceInfoDO::getIp, reqVO.getIp())
                .eqIfPresent(DataSourceInfoDO::getPort, reqVO.getPort())
                .likeIfPresent(DataSourceInfoDO::getUsername, reqVO.getUsername())
                .eqIfPresent(DataSourceInfoDO::getPwd, reqVO.getPwd())
                .eqIfPresent(DataSourceInfoDO::getTopicEew, reqVO.getTopicEew())
                .eqIfPresent(DataSourceInfoDO::getTopicEqr, reqVO.getTopicEqr())
                .eqIfPresent(DataSourceInfoDO::getTopicAckFirst, reqVO.getTopicAckFirst())
                .eqIfPresent(DataSourceInfoDO::getTopicAckSecond, reqVO.getTopicAckSecond())
                .betweenIfPresent(DataSourceInfoDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DataSourceInfoDO::getSourceId, reqVO.getSourceId())
                .orderByDesc(DataSourceInfoDO::getId));
    }
}